// 需求：定义Person类，属性：名字和年龄，方法：吃饭

void main() {
  Person man = new Person(name: '张三', age: 18, gender: '男');
  man.sayHello();

  Person woman = new Person(name: '小美', age: 18, gender: '女');
  woman.sayHello();
}

class Person {
  String? name;
  int? age;
  String? gender;
  //同名(主)构造函数
  Person({String? name, int? age, String? gender}) {
    print('主构造函数');
    this.name = name;
    this.age = age;
    this.gender = gender;
  }

  void sayHello() {
    print('我是$name,今年$age,性别$gender');
  }
}
